how count number of occurrences of a character in a string